﻿using System;

namespace SalePromotion.Pagination
{
    public sealed class PaginationOptions
    {
        private readonly int _itemsPerPage;
        private readonly int _currentPage;

        public PaginationOptions(int itemsPerPage, int currentPage = 1)
        {
            if (itemsPerPage < 1)
                throw new ArgumentOutOfRangeException("itemsPerPage", "Must have at least one item per page");

            if (currentPage < 1)
                throw new ArgumentOutOfRangeException("currentPage", "Current page must be one or more");
            
            _currentPage = currentPage;
            _itemsPerPage = itemsPerPage;
        }

        public int ItemsPerPage
        {
            get { return _itemsPerPage; }
        }

        public int CurrentPage
        {
            get { return _currentPage; }
        }

        public int SkipTo
        {
            get { return (_currentPage - 1) * ItemsPerPage; }
        }
    }
}
